import { Component } from "react";
import { FormHelper } from "../form-helper";
import { WebSiteDomain } from "../model/website.model";
import websiteService from "../service/website.service";

export interface IWebsiteItem { 
    name: string;
    key: string;
    value?: string;
}

export default class Website extends Component { 
    state = {
        website: new WebSiteDomain()
    }
    onSubmit = async (fields: any) => { 
        await websiteService.add(fields);
        alert("修改成功");
    }

    async componentDidMount() { 
        let website = await websiteService.get();
        this.setState({ website });
    }

    render() { 
        return FormHelper.create(this.state.website, 'website', this.onSubmit);
    }
}